package com.rt.schedulenew.web;

import com.rt.schedulebase.dto.terminal.QueryScheduledApplyDto;
import com.rt.schedulenew.api.IExamApplyService;
import com.rt.schedulenew.utils.global.JsonResult;
import com.rt.schedulenew.utils.global.JsonResultUtil;
import com.rt.schedulenew.utils.global.LocalLock;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping({"/public"})
public class PublicController {

    @Autowired
    private IExamApplyService examApplyService;

    @ApiOperation(value = "凭条打印", httpMethod = "POST", notes = "预约凭条打印")
    @PostMapping({"/schedule/print"})
    @LocalLock(key = "localLock:arg[0]")
    public JsonResult print(@RequestBody QueryScheduledApplyDto dto) {
        // 获取最近预约的申请单列表
        List<Object> print = examApplyService.getScheduledList(dto);
        return JsonResultUtil.success(print);
    }
}
